<?php
error_reporting(E_ALL);
include_once $_SERVER['DOCUMENT_ROOT']."/resources/Classes/access_user/access_user_class.php";

//dichiarazione delle variabili accettate
$action = "";
if (array_key_exists("action", $_POST))
{
	$action = $_POST['action'];
}
$Username = "";
if (array_key_exists("Username", $_POST))
{
	$Username = $_POST['Username'];
}
$Password = "";
if (array_key_exists("Password", $_POST))
{
	$Password = $_POST['Password'];
}
$RealName = "";
if (array_key_exists("RealName", $_POST))
{
	$RealName = $_POST['RealName'];
}
$Email = "";
if (array_key_exists("Email", $_POST))
{
	$Email = $_POST['Email'];
}

switch ($action) 
{
	case "List":
		
		$toJson = Access_user::get_users();
		echo json_encode($toJson);
		
		break;
		
		
	case "load":
		
		$toJson = Access_user::get_user();
		echo json_encode($toJson);
		
		break;
		
		
	case "save":
		
		echo Access_user::SaveUser($Username, $Password, $RealName, $Email);
		
		
		break;
		
	case "delete":
		break;
		
}